<?php


namespace App\Http\Controllers\Api;


use App\Api\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Models\ReceivePaymentHeader;
use App\Models\WtRequest;

class ReceivePaymentHeaderController extends Controller
{
    use ApiResponse;

    public function store()
    {
        $all = request()->all();

//        WtRequest::query()->create(
//            [
//                'post' => $_POST,
//                'server' => $_SERVER,
//                'data' => request()->all(),
//            ]
//        );

//        $arr = [
//            "DocCode" => "NAC200800523",
//            "DocDate" => "2020-08-18 00=>00=>00.000",
//            "Doctype" => "收到货款",
//            "periodid" => "2020-08",
//            "FormID" => "3101",
//            "cashcode" => "10020201",
//            "cashName" => "建行折7793",
//            "HDText" => "M收货款",
//            "DocStatus" => "50",
//            "EnterName" => "谭敏菁",
//            "EnterDate" => "2020-08-18 09=>33=>20.000",
//            "ObjType" => "客户",
//            "paymethod" => "转账",
//            "orgid" => "022303",
//            "orgname" => "名典二大区8销区(2020)",
//            "oppocompanyid" => "00211035-16",
//            "oppocompanyname" => "山东省莱州市(郭大海)",
//            "hdamount" => "4655.0000",
//        ];
        try {
            if (ReceivePaymentHeader::query()->where('DocCode', $all['DocCode'])->doesntExist()) {
                ReceivePaymentHeader::query()->create($all);
            }
        } catch (\Exception $e) {
            return $this->failed("数据插入失败");
        }

        return $this->message('数据插入成功');
    }

}